/*    */ package blockbuster.math.functions;
/*    */ 
/*    */ import blockbuster.math.Constant;
/*    */ import blockbuster.math.IValue;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public abstract class Function
/*    */   implements IValue
/*    */ {
/*    */   protected IValue[] args;
/*    */   protected String name;
/* 17 */   protected IValue result = (IValue)new Constant(0.0D);
/*    */ 
/*    */   
/*    */   public Function(IValue[] values, String name) throws Exception {
/* 21 */     if (values.length < getRequiredArguments()) {
/*    */       
/* 23 */       String message = String.format("Function '%s' requires at least %s arguments. %s are given!", new Object[] { getName(), Integer.valueOf(getRequiredArguments()), Integer.valueOf(values.length) });
/*    */       
/* 25 */       throw new Exception(message);
/*    */     } 
/*    */     
/* 28 */     for (int i = 0; i < values.length; i++)
/*    */     {
/* 30 */       verifyArgument(i, values[i]);
/*    */     }
/*    */     
/* 33 */     this.args = values;
/* 34 */     this.name = name;
/*    */   }
/*    */ 
/*    */ 
/*    */ 
/*    */   
/*    */   protected void verifyArgument(int index, IValue value) {}
/*    */ 
/*    */ 
/*    */   
/*    */   public void set(double value) {}
/*    */ 
/*    */ 
/*    */   
/*    */   public void set(String value) {}
/*    */ 
/*    */ 
/*    */   
/*    */   public IValue getArg(int index) {
/* 53 */     if (index < 0 || index >= this.args.length)
/*    */     {
/* 55 */       throw new IllegalStateException("Index should be within the argument's length range! Given " + index + ", arguments length: " + this.args.length);
/*    */     }
/*    */     
/* 58 */     return this.args[index].get();
/*    */   }
/*    */ 
/*    */ 
/*    */   
/*    */   public String toString() {
/* 64 */     String args = "";
/*    */     
/* 66 */     for (int i = 0; i < this.args.length; i++) {
/*    */       
/* 68 */       args = args + this.args[i].toString();
/*    */       
/* 70 */       if (i < this.args.length - 1)
/*    */       {
/* 72 */         args = args + ", ";
/*    */       }
/*    */     } 
/*    */     
/* 76 */     return getName() + "(" + args + ")";
/*    */   }
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */   
/*    */   public String getName() {
/* 84 */     return this.name;
/*    */   }
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */   
/*    */   public int getRequiredArguments() {
/* 92 */     return 0;
/*    */   }
/*    */ }


/* Location:              D:\fanbian\[D][龙之核心]DragonCore-2.6.0.3.jar!\blockbuster\math\functions\Function.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */